open Type_printer
open Ast_printer
open Common

let print_package_rule = function		
	| Forbidden -> print_string "[ Forbidden ]"
	| Directory ( path ) -> print_string ( "[ Directory : " ^ path ^ " ]" )
	| Remap ( p ) -> print_string ( "[ Remap : " ^ p ^ " ]"	)
	
let print_platform = function
	| Cross -> print_string "cross"
	| Js -> print_string "js"
	| Php -> print_string "php"
	| Flash -> print_string "flash"
	| Flash9 -> print_string "flash9"
	| Cpp -> print_string "cpp"
	| Jvm -> print_string "jvm" 
	| Neko -> print_string "neko"

let print_ctx ctx =
	
	print_endline ( "[ HaXe Version : " ^ (string_of_int ctx.version) ^ " ]" ) ;
	print_endline ( "[ Debug? : " ^ (string_of_bool ctx.debug) ^ " ]" ) ;
	print_endline ( "[ Verbose? : " ^ (string_of_bool ctx.verbose) ^ " ]" ) ;
	print_endline ( "[ FOptimize? : " ^ (string_of_bool ctx.foptimize) ^ " ]" ) ;
	
	print_string "[ Platform : " ;
	print_platform ctx.platform ;
	print_endline " ]";	
			
	print_string "[ Classpath : " ;
	List.iter (fun str -> print_string ( str ^ ", " ) ) ctx.class_path ; 
	print_endline " ]";
	
	print_string "[ Main class : " ;
	( match ctx.main_class with None -> () | Some ( path ) -> print_path path ) ;
	print_endline " ]";
	
	print_string "[ Defines : " ;
	let print_first f i = print_string (f ^ ", ") 
		in PMap.iter print_first ctx.defines;
	print_endline " ]";
		
	print_string "[ Package rules : " ;
	let print_both a b = print_string (a ^ " -> ") ; print_package_rule b ; print_string " | "
		in PMap.iter print_both ctx.package_rules ;
	print_endline " ]";
			
	print_string "[ Js namespace : " ; 
	( match ctx.js_namespace with None -> () | Some ( jsn ) -> print_string jsn ) ;
	print_endline " ]";
			
	print_endline ( "[ Output file : " ^ ctx.file ^ " ]") ;
	
	print_endline ( "[ Flash version : " ^ (string_of_int ctx.flash_version) ^ " ]") ;
	
	print_string "[ Types : " ;
	List.iter print_module_type ctx.types ;
	print_endline " ]";

	print_string "[ Resources : " ;
	let print_2strings a  b = print_string ( a ^ " -> " ^ b ) 
	in Hashtbl.iter print_2strings ctx.resources ;
	print_endline " ]";
	
	print_string "[ Php_front : " ;
	( match ctx.php_front with None -> () | Some ( s ) -> print_string s ) ;
	print_endline " ]";
	
	print_string "[ SWF Libraries : " ;
	List.iter (fun ( a , _ , _ ) -> print_string a  ) ctx.swf_libs ;
	print_endline " ]";